/****************************************************************************
 *Copyright(C),2024, Ningbo Tuopu Group Co., Ltd.
 *FileName:   MotAsp_Cfg.c
 *Date:       2024-12-16 19:03:04
 *Author:     TianGui.Wang
 *Version:    0
 *Path:       
 *Description:
 ****************************************************************************/
/****************************************************************************/
/*                             Include area                                 */
/****************************************************************************/
/* PRQA S 0380++ # M3CM-2_2-C99:Dir-1.1-C99 Number of macro definitions exceeds 4095
 * Reason: RTE error doesn't need to be repaired.*/
#include "MotAsp/MotAsp_Cfg.h"
/* PRQA S 0380--*/

/****************************************************************************/
/*                             Definition area                              */
/****************************************************************************/

/****************************************************************************/
/*                             Typedef area                                 */
/****************************************************************************/

/****************************************************************************/
/*                             Local data at RAM                            */
/****************************************************************************/

/****************************************************************************/
/*                             Global data at RAM                           */
/****************************************************************************/

/****************************************************************************/
/*                        Global data at RAM declare area                   */
/****************************************************************************/

/****************************************************************************/
/*                             Local data at ROM                            */
/****************************************************************************/

/****************************************************************************/
/*                             Global data at ROM                           */
/****************************************************************************/

/****************************************************************************/
/*                        Global data at ROM declare area                   */
/****************************************************************************/
/*          [0] - SIN- Range --------- MotAsp_Lib_SIN_0, 
            [1] - SIN+ Range --------- MotAsp_Lib_SIN_1,  
            [2] - COS- Range --------- MotAsp_Lib_COS_0,  
            [3] - COS+ Range --------- MotAsp_Lib_COS_1, 
*/

/************************************************   MPS   ****************************************************** */
MotAsp_Lib_SIG_V_RANGE_TYPE MotAsp_Cfg_SiCo_V_Range_Para[MotAsp_Lib_SIN_COS_SIG_NUM] = {
    [MotAsp_Lib_SIN_0] = {
        .Min_V                  =           MOTASP_CFG_DIAG_SIN0_AD_GND_VAL,
        .Min_Allow              =           MOTASP_CFG_DIAG_SIN0_AD_MIN_VAL,
        .Max_Allow              =           MOTASP_CFG_DIAG_SIN0_AD_MAX_VAL,
        .Max_V                  =           MOTASP_CFG_DIAG_SIN0_AD_VBAT_VAL
    },      
    [MotAsp_Lib_SIN_1] = {      
        .Min_V                  =           MOTASP_CFG_DIAG_SIN1_AD_GND_VAL,
        .Min_Allow              =           MOTASP_CFG_DIAG_SIN1_AD_MIN_VAL,
        .Max_Allow              =           MOTASP_CFG_DIAG_SIN1_AD_MAX_VAL,
        .Max_V                  =           MOTASP_CFG_DIAG_SIN1_AD_VBAT_VAL
    },      
    [MotAsp_Lib_COS_0] = {      
        .Min_V                  =           MOTASP_CFG_DIAG_COS0_AD_GND_VAL,
        .Min_Allow              =           MOTASP_CFG_DIAG_COS0_AD_MIN_VAL,
        .Max_Allow              =           MOTASP_CFG_DIAG_COS0_AD_MAX_VAL,
        .Max_V                  =           MOTASP_CFG_DIAG_COS0_AD_VBAT_VAL
    },      
    [MotAsp_Lib_COS_1] = {      
        .Min_V                  =           MOTASP_CFG_DIAG_COS1_AD_GND_VAL,
        .Min_Allow              =           MOTASP_CFG_DIAG_COS1_AD_MIN_VAL,
        .Max_Allow              =           MOTASP_CFG_DIAG_COS1_AD_MAX_VAL,
        .Max_V                  =           MOTASP_CFG_DIAG_COS1_AD_VBAT_VAL
    },
};

MotAsp_Lib_CNT_STATUS MotAsp_Cfg_Sin_Cos_i_Cnt_Para[MotAsp_Lib_SIN_COS_SIG_NUM] = {
    [MotAsp_Lib_SIN_0] = {
        .CNT                    =           MOTASP_CFG_SIN0_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },          
    [MotAsp_Lib_SIN_1] = {          
        .CNT                    =           MOTASP_CFG_SIN1_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },          
    [MotAsp_Lib_COS_0] = {          
        .CNT                    =           MOTASP_CFG_COS0_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },          
    [MotAsp_Lib_COS_1] = {          
        .CNT                    =           MOTASP_CFG_COS1_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },
};


MotAsp_Lib_SINCOS_CALIB_PARA_STATUS MotAsp_Cfg_SiCo_Calib_Para = {
    .Limit_Min                  =           MOTASP_CFG_SICO_DEFAULT_BASICMININIT,
    .Limit_Mid                  =           MOTASP_CFG_SICO_DEFAULT_OFFSETINIT,
    .Limit_Max                  =           MOTASP_CFG_SICO_DEFAULT_BASICMAXINIT,
    .Diff_V                     =           MOTASP_CFG_SICO_BASICMININIT_CALIB_DIFF_V
};

MotAsp_Lib_CNT_STATUS MotAsp_Cfg_SiCo_Cnt_Para = {
    .CNT                        =           MOTASP_CFG_SIN_COS_CNT_TIME,
    .cnt                        =           0U,
    .Sig                        =           MotAsp_Base_InValid,
};


int16_T MotAsp_Cfg_Sin_Arr[MOTASP_CFG_FILTER_SIN_ARR_CNT] = {0};
int16_T MotAsp_Cfg_Cos_Arr[MOTASP_CFG_FILTER_COS_ARR_CNT] = {0};

MotAsp_Lib_SINCOS_SIMP_MID_AVG_FILTE_STAUTS MotAsp_Cfg_Sin_Filter_Para[MotAsp_Lib_SiCo_NUM] = {
    [MotAsp_Lib_SiCo_Sin] = {
        .Calc_Gain              =           MOTASP_CFG_FILTER_SIN_GAIN,
        .Simp_Arr_CNT           =           MOTASP_CFG_FILTER_SIN_ARR_CNT,
        .Simp_Arr_Dislay        =           &(MotAsp_Cfg_Sin_Arr[0]),

        .Limit_Calib            =           MOTASP_CFG_MSP_SICO_I_AD_RAW_MIN_VAL,
    },          

    [MotAsp_Lib_SiCo_Cos] = {           
        .Calc_Gain              =           MOTASP_CFG_FILTER_COS_GAIN,
        .Simp_Arr_CNT           =           MOTASP_CFG_FILTER_COS_ARR_CNT,
        .Simp_Arr_Dislay        =           &(MotAsp_Cfg_Cos_Arr[0]),
        
        .Limit_Calib            =           MOTASP_CFG_MSP_SICO_I_AD_RAW_MIN_VAL,
    },
};


MotAsp_Lib_SINCOS_CALC_MINMAX_ALGTH_STATUS MotAsp_Cfg_Calc_MIA_Algth_Para[MotAsp_Lib_SiCo_NUM] = {
    [MotAsp_Lib_SiCo_Sin] = {
        .Center_Point           =           MOTASP_CFG_CALC_SIN_MINMAX_CENTER,
        .Amplitude              =           MOTASP_CFG_CALC_SIN_MINMAX_AMPLITUTE,
    },          

    [MotAsp_Lib_SiCo_Cos] = {           
        .Center_Point           =           MOTASP_CFG_CALC_COS_MINMAX_CENTER,
        .Amplitude              =           MOTASP_CFG_CALC_COS_MINMAX_AMPLITUTE,   
    },
};

MotAsp_Lib_SINCOS_CALC_CENTER_INTERIM_STATUS MotAsp_Cfg_Pi_Para[MotAsp_Lib_SIN_COS_SIG_NUM] = {
    [MotAsp_Lib_SIN_0] = {
        .Calc_G                 =           MOTASP_CFG_PI_MIN_SIN_GAIN,
        .Calc_molecule0         =           MOTASP_CFG_PI_MIN_SIN_MOLECULE,
        .Calc_numerator0        =           MOTASP_CFG_PI_MIN_SIN_NUMERATOR,

        .Init_Sig               =           MotAsp_Base_InValid,
    },
    [MotAsp_Lib_SIN_1] = {
        .Calc_G                 =           MOTASP_CFG_PI_MAX_SIN_GAIN,
        .Calc_molecule0         =           MOTASP_CFG_PI_MAX_SIN_MOLECULE,
        .Calc_numerator0        =           MOTASP_CFG_PI_MAX_SIN_NUMERATOR, 
        .Init_Sig               =           MotAsp_Base_InValid,       
    },
    [MotAsp_Lib_COS_0] = {
        .Calc_G                 =           MOTASP_CFG_PI_MIN_COS_GAIN,
        .Calc_molecule0         =           MOTASP_CFG_PI_MIN_COS_MOLECULE,
        .Calc_numerator0        =           MOTASP_CFG_PI_MIN_COS_NUMERATOR, 
        .Init_Sig               =           MotAsp_Base_InValid,       
    },
    [MotAsp_Lib_COS_1] = {
        .Calc_G                 =           MOTASP_CFG_PI_MAX_COS_GAIN,
        .Calc_molecule0         =           MOTASP_CFG_PI_MAX_COS_MOLECULE,
        .Calc_numerator0        =           MOTASP_CFG_PI_MAX_COS_NUMERATOR, 
        .Init_Sig               =           MotAsp_Base_InValid,        
    },
};

MotAsp_Lib_SINCOS_CALC_LOGIC_STATUS MotAsp_Cfg_Calc_MIA_Para[MotAsp_Lib_SiCo_NUM] = {
    [MotAsp_Lib_SiCo_Sin] = {
        .Arr_CNT                =           MOTASP_CFG_CALC_SIN_MIA_CNT,
        .Ratio                  =           MOTASP_CFG_CALC_SIN_MIA_RATIO,
        .Init =         
        {           
            .Min                =           MOTASP_CFG_CALC_SIN_MIN_INIT,
            .Max                =           MOTASP_CFG_CALC_SIN_MAX_INIT,
        }
    },

    [MotAsp_Lib_SiCo_Cos] = {
        .Arr_CNT                =           MOTASP_CFG_CALC_COS_MIA_CNT,
        .Ratio                  =           MOTASP_CFG_CALC_COS_MIA_RATIO,
        .Init =                 
        {                   
            .Min                =           MOTASP_CFG_CALC_COS_MIN_INIT,
            .Max                =           MOTASP_CFG_CALC_COS_MAX_INIT,
        }   
    },
};

MotAsp_Lib_CNT_STATUS MotAsp_Cfg_SiCo_MIN_Cnt_Para[MotAsp_Lib_SIN_COS_SIG_NUM] = {
    [MotAsp_Lib_SIN_0] = {
        .CNT                    =           MOTASP_CFG_SIN_MIN_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },
    [MotAsp_Lib_SIN_1] = {
        .CNT                    =           MOTASP_CFG_SIN_MAX_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },
    [MotAsp_Lib_COS_0] = {
        .CNT                    =           MOTASP_CFG_COS_MIN_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },
    [MotAsp_Lib_COS_1] = {
        .CNT                    =           MOTASP_CFG_COS_MAX_CNT_TIME,
        .cnt                    =           0U,
        .Sig                    =           MotAsp_Base_InValid,
    },
};


MotAsp_Lib_SINCOS_TRACK_COORDINATE_STATUS MotAsp_Cfg_Calc_Arctan_Para = {
    .ArcTan45_Arr_Num           =           MOTASP_CFG_CALC_ARCTAN_ARR_NUM,
    .Degrees_90                 =           MOTASP_CFG_CALC_ARCTAN_DEGREES_90,
};


MotAsp_Lib_ANGLE_INCREMENT_STAUTS MotAsp_Cfg_Calc_Angle_Para = {
    .Poles                      =           MOTASP_CFG_MOTOR_POLES,
    .Degrees_180                =           MOTASP_CFG_CALC_ARCTAN_DEGREES_180,
    .Degrees_360                =           MOTASP_CFG_CALC_ARCTAN_DEGREES_360,
};


MotAsp_Lib_COORDINATE_BASIC_ANGLE_STATE MotAsp_Cfg_Quadrant_Basic = {
    .Quad_I                     =           MOTASP_CFG_QUADRANT_I,
    .Quad_II                    =           MOTASP_CFG_QUADRANT_II,
    .Quad_III                   =           MOTASP_CFG_QUADRANT_III,
    .Quad_IV                    =           MOTASP_CFG_QUADRANT_IV,
};

/************************************************   MPS   ****************************************************** */

MotAsp_Type_VIRTUAL_CALC_STRUCT MotAsp_Cfg_Virtual = {
    .Max_Angle                  =           MOTASP_CFG_MOTOR_CYCLE_MAX_VAL,
    .Poles                      =           MOTASP_CFG_MOTOR_POLES,
    .Min_To_Cycle               =           MOTASP_CFG_MIN_TO_PERIOD,
    .Rpm_Step                   =           MOTASP_CFG_VIRTUAL_START_SPD,
};


uint16_T MotAsp_Cfg_Spd_Simp_Arr[MOTASP_CFG_SPD_SIMP_ARR_NUM] = {0};

MotAsp_Type_SPD_SIMPLE_STRUCT MotAsp_Cfg_Spd_Simp = {
    .CNT                        =           MOTASP_CFG_SPD_SIMP_ARR_NUM,
    .Date                       =           &(MotAsp_Cfg_Spd_Simp_Arr[0]),
};


MotAsp_Type_SPD_CALC_STRUCT MotAsp_Cfg_Spd_Calc = {
    .CNT                        =           MOTASP_CFG_SPD_SIMP_ARR_NUM,
    .Date                       =           &(MotAsp_Cfg_Spd_Simp_Arr[0]),
    .Poles                      =           MOTASP_CFG_MOTOR_POLES,
    .Max_Angle                  =           MOTASP_CFG_MOTOR_CYCLE_MAX_VAL,
    .Min_To_Cycle               =           MOTASP_CFG_MIN_SPD_TO_PERIOD,
    .molecule0                  =           MOTASP_CFG_SPD_CALC_MOLECULE0,
    .numerator0                 =           MOTASP_CFG_SPD_CALC_NUMERATOR0,
    .molecule1                  =           MOTASP_CFG_SPD_CALC_MOLECULE1,
    .numerator1                 =           MOTASP_CFG_SPD_CALC_NUMERATOR1,
};


MotAsp_Type_ABS_POS_CALC_STRUCT MotAsp_Cfg_Abs_Pos = 
{
    .Max_Angle                  =           MOTASP_CFG_MOTOR_CYCLE_MAX_VAL,
    .Poles                      =           MOTASP_CFG_MOTOR_POLES,
    .Lead_Screw                 =           MOTASP_CFG_MOTOR_SCREW_LEAD,
};


MotAsp_Type_ABS_POS_CALC_STRUCT MotAsp_Cfg_Rel_Pos = 
{
    .Max_Angle                  =           MOTASP_CFG_MOTOR_CYCLE_MAX_VAL,
    .Poles                      =           MOTASP_CFG_MOTOR_POLES,
    .Lead_Screw                 =           MOTASP_CFG_MOTOR_SCREW_LEAD,
};

/****************************************************************************/
/*                        Local function declare area                       */
/****************************************************************************/

/****************************************************************************/
/*                        Global function declare area                      */
/****************************************************************************/

/****************************************************************************/
/*                      Global function Implementation area                 */
/****************************************************************************/

/****************************************************************************/
/*                      Local function Implementation area                  */
/****************************************************************************/